//
//  GTTabBarViewController.m
//  GiftTalk
//
//  Created by justaway on 15/8/14.
//  Copyright (c) 2015年 swiftyper. All rights reserved.
//

#import "GTTabBarController.h"
#import "HomeViewController.h"
#import "GiftViewController.h"
#import "CategoryViewController.h"
#import "MeViewController.h"

@interface GTTabBarController ()

@end

@implementation GTTabBarController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    [self initChildViewControllers];
}

- (void)initChildViewControllers {
    
    HomeViewController *homeController = [[HomeViewController alloc] init];
    [self addChildViewController:homeController title:@"礼物说" iamgeName:@"TabBar_home" selectedImageName:@"TabBar_home_selected"];
    
    UIStoryboard *giftStoryboard = [UIStoryboard storyboardWithName:@"Gift" bundle:nil];
    GiftViewController *giftController = [giftStoryboard instantiateInitialViewController];
    [self addChildViewController:giftController title:@"单品" iamgeName:@"TabBar_gift" selectedImageName:@"TabBar_gift_selected"];
    
    CategoryViewController *categoryController = [[CategoryViewController alloc] init];
    [self addChildViewController:categoryController title:@"分类" iamgeName:@"TabBar_category" selectedImageName:@"TabBar_category_Selected"];
    
    MeViewController *meController = [[MeViewController alloc] init];
    [self addChildViewController:meController title:@"我" iamgeName:@"TabBar_me_boy" selectedImageName:@"TabBar_me_boy_selected"];
}

- (void)addChildViewController:(UIViewController *)controller
                         title:(NSString *)title
                     iamgeName:(NSString *)imageName
          selectedImageName:(NSString *)selectedImageName {
    
    controller.title = title;
    
    controller.tabBarItem.image = [UIImage imageNamed:imageName];
    controller.tabBarItem.selectedImage = [UIImage imageNamed:selectedImageName];
    
    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:controller];
    
    [self addChildViewController:navController];
    
}

@end
